package cardGame;

import java.util.Arrays;
import java.util.Collections;
import java.util.Random;

public class HoyleDeck implements Deck {

	private Card[] deck = new Card[52];
	private int numLeft = deck.length;

	public HoyleDeck() {
		int i = 0;
		for (Card.Suit suit : Card.Suit.values()) {
			for (Card.FaceValue faceValue : Card.FaceValue.values()) {
				// cmd + 2
				deck[i++] = new Card(suit, faceValue);
			}

		}
	}
	
	@Override
	public int getNumCards() {
		return deck.length;
	}

	public void shuffle() {
		    Random randomSeed = new Random();
		    randomSeed.nextInt();
		    Random random = new Random(randomSeed.nextInt());
		    random.nextInt();
		    for (int i = 0; i < getNumCards(); i++) {
		      int newSpot = i + random.nextInt(getNumCards() - i);
		      Card helper = deck[i];
			    deck[i] = deck[newSpot];
			    deck[newSpot] = helper;
		    }
		  }

	@Override
	public Card deal(int numPlayers) {
		if ((int)(52/numPlayers) > ((52 - numLeft)/numPlayers))
			return deck[--numLeft];
		return null;
	}
	
	
//	public String toString() {
//		for (int i = 0; i < deck.length; i++){
//		return deck[i];
//		}
//	}

}
